package com.sfc.sdsr.common.model;

import java.io.Serializable;
import java.net.URL;
import java.util.UUID;

public class Event implements IFileDao, Serializable, Comparable<Event> {
	
	private static final long serialVersionUID = 0xDEADBEEFBABE0002L;

	private UUID eventUid;
	private String eventName;
	private String reason;
	private Address address;
	private Person organizer;
	private URL webpage;
	private Long utcEventDate;
	private String extraString;
	
	public UUID getEventUid() {
		return eventUid;
	}

	public void setEventUid(UUID eventUid) {
		this.eventUid = eventUid;
	}

	public String getEventName() {
		return eventName;
	}

	public void setEventName(String eventName) {
		this.eventName = eventName;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public Person getOrganizer() {
		return organizer;
	}

	public void setOrganizer(Person organizer) {
		this.organizer = organizer;
	}

	public URL getWebpage() {
		return webpage;
	}

	public void setWebpage(URL webpage) {
		this.webpage = webpage;
	}

	public Long getUtcEventDate() {
		return utcEventDate;
	}

	public void setUtcEventDate(Long utcEventDate) {
		this.utcEventDate = utcEventDate;
	}

	public String getExtraString() {
		return extraString;
	}

	public void setExtraString(String extraString) {
		this.extraString = extraString;
	}

	@Override
	public String getPrimaryKey() {
	    return (this.eventName + this.getUtcEventDate()).toLowerCase();
	}
	
	/**
	 * events can't occur at the same time, time stamp is the primary key
	 */
	@Override
	public int compareTo(Event event) {
	    if (this == event) {
	        return 0;
	    }

	    String otherPrimaryKey = event.getPrimaryKey();
	    String thisPrimaryKey = this.getPrimaryKey();
	    
	    return thisPrimaryKey.compareTo(otherPrimaryKey);
	}

    @Override
    public String toString() {
        return "Event: " + this.eventName + " " + this.getUtcEventDate();
    }

}
